package com.itheima.reggie.common;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Component;

/**
 * 维护本地线程的工具类
 */
@Component
public class BaseContext {

    private BaseContext(){}

    //定义一个本地线程对象
    private static ThreadLocal<Long> THREAD_LOCAL = new ThreadLocal<>();

    //提供静态方法，设置数据
    public static void setCurrentId(Long employeeId){
        THREAD_LOCAL.set(employeeId);
    }

    //提供静态方法，获取数据
    public static Long getCurrentId(){
        Long employeeId = THREAD_LOCAL.get();
        return employeeId;
    }

}
